/*
 * TODO: Description
 *
 * Copyright (C) 2010 Johan Waldeback
 *  
 * This file is part of the OpenFMS project (http://www.openfms-project.org)
 * 
 * OpenFMS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __BULLETTICKLISTENER_H__
#define __BULLETTICKLISTENER_H__

#include <BulletDynamics/Dynamics/btDynamicsWorld.h>
#include <OgreFrameListener.h>
#include <deque>

class BulletTickListener
{
public:
	virtual ~BulletTickListener();
	virtual void onTick(const btDynamicsWorld *world, btScalar timeStep);
	virtual void onFrameStarted(const Ogre::FrameEvent &evt);
};

class BulletTickListenerList
{
private:
	typedef std::deque<BulletTickListener *> ListType ;
	ListType m_listeners;
public:
	BulletTickListenerList();
	~BulletTickListenerList();
	void attach( btDynamicsWorld *world );
	void detach();
	void addListener(BulletTickListener *pListener);
	void removeAllListeners( bool freeItems =true );
	void destroy();

	void onTick(const btDynamicsWorld *world, btScalar timeStep);
	void onFrameStarted(const Ogre::FrameEvent &evt);
};


#endif //__BULLETTICKLISTENER_H__
